﻿using gt.UserInfo.DomainModels.Abstractions;
using gt.UserInfo.DomainModels.ApiRequests;
using gt.UserInfo.DomainModels.ViewObject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace gt.UserInfo.ApplicationServices.Impl
{
    public class UserAppService : IUserAppService
    {
        private readonly IUserDomainService _userDomainService;

        public UserAppService(IUserDomainService userDomainService)
        {
            _userDomainService = userDomainService;
        }

        public async Task<UserVO> LoginAsync(string name, string password)
        {
            return await _userDomainService.LoginAsync(name, password);
        }

        public async Task<int> RegisterAsync(RegisterUserRequest request)
        {
            var userVO = new UserVO
            {
                Age = request.Age,
                Introduce = request.Introduce,
                Name = request.Name,
                ShowName = request.ShowName,
                Password = request.Password,
                Phone = request.Phone,
                Sex = request.Sex
            };

            return await _userDomainService.RegisterAsync(userVO);
        }
    }
}
